#ifndef TOKENIZER_H
#define TOKENIZER_H

#include "inc.h"
#include "myerr.h"

#define MAX_TOKEN_SIZE 32

#define STMT_SELECT "select user_id, name " \
                    "from user " \
                    "join book " \
                    "where user_id == 1 and name == 'jack' or email > 'aacom'"

#define STMT_UPDATE "update user " \
                    "set email = 'aacom', name = 'jack' " \
                    "join borrow " \
                    "where user_id == 2 and name == 'jack' or email < 'b'"

#define STMT_DELETE "delete from user " \
                    "join book, borrow " \
                    "where book_id == 4 and author == 'john' or status == 2"

#define STMT_INSERT "insert into book values (jack, 1, 43), (john, 4, 24)"

typedef enum {
    TOKEN_SELECT, TOKEN_FROM, TOKEN_WHERE, TOKEN_IDENTIFIER, 
    TOKEN_NUMBER, TOKEN_GREATER, TOKEN_LESS, TOKEN_EQUAL,
    TOKEN_GE, TOKEN_LE, TOKEN_NE, TOKEN_AND, TOKEN_OR,
    TOKEN_STRING, TOKEN_COMMA, TOKEN_STAR, TOKEN_EOF,
    TOKEN_INSERT, TOKEN_INTO, TOKEN_DELETE, TOKEN_UPDATE,
    TOKEN_VALUES, TOKEN_ASSIGN, TOKEN_SET, TOKEN_LP, TOKEN_RP,
    TOKEN_JOIN, TOKEN_INVALID
} TokenType;

typedef struct {
    TokenType type;
    char value[MAX_TOKEN_SIZE];
} Token;

typedef Token Keyword;
typedef Token Operator;

Token getNextToken(const char *sql, int *index, int *last_index);

#endif  /* TOKENIZER_H */